package com.gfl.trivialrestclient.dao.hibernate;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.gfl.trivialrestclient.dao.UserDao;
import com.gfl.trivialrestclient.model.User;

@Repository(value = "userDao")
public class UserDaoHibernate extends GenericDaoHibernate<User, Long> implements
		UserDao {

	@Transactional(readOnly = true)
	@Override
	public User findByUsername(String username) {
		User user = (User) getSessionFactory().getCurrentSession()
				.getNamedQuery("User.findByUsername")
				.setString("username", username).uniqueResult();
		return user;
	}

}
